package cn.mysocketnet.a07test1;

import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
    public static void main(String[] args) {
        //客户端：多次发送数据
        //服务器：接收多次接收数据，并打印

        //1.创建对象绑定10000端口
        try(ServerSocket ss = new ServerSocket(10000)){
            Socket socket = ss.accept();
            InputStreamReader reader = new InputStreamReader(socket.getInputStream());
            char[] chars = new char[1024];
            int len;
            while ((len=reader.read(chars))!=-1){
                System.out.println(new String(chars,0,len));
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
